/*package com.smarttest.portal.service.timertask;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.TimeUnit;

import javax.annotation.PostConstruct;

import org.apache.commons.lang3.StringUtils;
import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;

import com.alibaba.fastjson.JSONObject;
import com.smarttest.portal.service.RangeStopCountService;

@Service
public class StopEventTimer {

	@Value("${runtimertask:false}")
	private String runtimertask = "false";
	@Value("${stopruntime}")
	private String stopruntime;
	
	private static final Logger log = Logger.getLogger(StopEventTimer.class);
	private ScheduledExecutorService scheduledExecutorService = Executors
			.newSingleThreadScheduledExecutor();
	
	@Autowired
	StopRefreshMonitor stopRefreshMonitor ;
	@Autowired
	RangeStopCountService rangeStopCountService;
	
	@PostConstruct
	public void init() {
		if (StringUtils.equalsIgnoreCase("true", runtimertask)) {
			log.info("StopEventCount init-" + Thread.currentThread().getName());
			long oneDay = 24 * 60 * 60 * 1000;
			long initDelay = getTimeMillis(stopruntime)
					- System.currentTimeMillis();
			initDelay = initDelay > 0 ? initDelay : oneDay + initDelay;
			scheduledExecutorService.scheduleWithFixedDelay(new Runnable() {

				@Override
				public void run() {
					stopEventCount();
				}

			}, initDelay, oneDay, TimeUnit.MILLISECONDS);
		}
	}

	private long getTimeMillis(String time) {
		Calendar c = Calendar.getInstance();
		String day = new SimpleDateFormat("yyyyMMdd").format(c.getTime());

		day = day + time;
		try {
			return new SimpleDateFormat("yyyyMMddHH:mm:ss").parse(day)
					.getTime();
		} catch (ParseException e) {
			e.printStackTrace();
			log.error("error day:" + day);
			return 0;
		}
	}
	
	private void stopEventCount() {
		JSONObject json = stopRefreshMonitor.getAllStopEvent();
		int stopEventBef = json.getIntValue("StopBefore");
		int stopEventAf = json.getIntValue("StopAfter");
		System.out.println("stopEventBef :"+stopEventBef+"    stopEventAf:"+stopEventAf);
		rangeStopCountService.insertEvent(9, stopEventBef, stopEventAf);
		
	}
}
*/